import java.util.Scanner;

public class LanQiaoPractice1 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int q = in.nextInt();
        int[] hash = new int[10001];
        int m = 0;
        int n = 0;
        in.nextLine();
        while (q-- > 0) {

            String line = in.nextLine();
            String[] parts = line.split(" ");
            for (String part : parts) {
                int cur = Integer.parseInt(part);
                if (hash[cur]++ > 0) {
                    n = cur;
                }
            }
        }

        int index = 0;
        while(hash[index] <= 0){
            index++;
        }

        for (int i = index; i < 10001; i++) {
            if(hash[i] == 0){
                m = i;

                break;
            }
        }
        System.out.print(m + " ");
        System.out.print(n);

    }
}
